<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="entities.GoodsEntity"%>
<%@ page import="service.GoodsService"%>
<%@ page import="java.math.BigDecimal"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String searchKey = request.getParameter("searchKey");
	//searchKey = new String(searchKey.getBytes("ISO-8859-1"), "UTF-8");
	List<GoodsEntity> goodsList = new ArrayList<GoodsEntity>();
	goodsList = GoodsService.indexSearchResult(searchKey);
	if (searchKey == null || searchKey == "" || goodsList.size() == 0) {
		response.setCharacterEncoding("UTF-8");
		response.sendRedirect(basePath + "searchclass.jsp");
	}
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>搜索页面</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
body {
	margin: auto;
	text-align: center;
}
</style>
</head>

<body>
	<jsp:include page="header.jsp"></jsp:include>
	<div style="height: 40px; "></div>
	<%
		for (GoodsEntity goods : goodsList) {
	%>
	<div style="width:230px;height:230px;float:left;margin-left:30px;">
		<a href="goodsDetail.jsp?goodsId=<%=goods.getId()%>"><img
			width="50%" height="50%" src="<%=goods.getImageUrl()%>"> </a>
		<div><%=goods.getName()%><span class="saleCount">￥<%=goods.getPrice()%></span><br>
			<span class="sale"> 销售量：</span><span class="saleCount"><%=goods.getSaleCount()%></span>
		</div>
	</div>

	<%
		}
	%>

</body>
</html>
